package com.tencent.qf.user.convert;

import com.tencent.qf.user.api.dto.UserDTO;
import com.tencent.qf.user.dal.TyOrder;
import com.tencent.qf.user.dto.UserVO;
import com.tencent.qf.user.dal.UserDO;
import com.tencent.qf.user.dto.response.OrderInfo;
import com.tencent.qf.user.dto.response.OrderInfoByUid;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

import java.util.List;

/**
 * Copyright (C) 2022 Limited, a Tencent company. All rights reserved.
 *
 * @author p_htaozhou@tencent.com
 * @create: 2022/9/7 17:22
 */

@Mapper
public interface UserConvert {
    UserConvert INSTANCE = Mappers.getMapper(UserConvert.class);

    UserVO userDOConvert2VO(UserDO userDO);

    UserDTO userDOConvert2DTO(UserDO userDO);

    @Mapping(target = "plainOrderId", source = "plainOrderId")
    @Mapping(target = "payedTime", source = "payedTime")
    @Mapping(target = "orderId", source = "externalOrderId")
    @Mapping(target = "skuId", source = "MExternalSkuId")
    @Mapping(target = "skuName", source = "MSkuNameChinese")
    @Mapping(target = "spuId", source = "MExternalSpuId")
    @Mapping(target = "spuName", source = "MSpuNameChinese")
    @Mapping(target = "storeName", source = "MStoreName")
    @Mapping(target = "goodsId", source = "MGoodsId")
    @Mapping(target = "primaryImageUrl", source = "MPrimaryImageUrl")
    @Mapping(target = "goodsNum", source = "MGoodsNum")
    @Mapping(target = "kaid", source = "MKaId")
    @Mapping(target = "commissionStatus", source = "commissionStatus")
    @Mapping(target = "apiContent", source = "apiContent")
    OrderInfo tyOrder2OrderInfo(TyOrder tyOrder);

    @Mapping(target = "storeId", source = "MExternalStoreId")
    @Mapping(target = "storeName", source = "MStoreName")
    @Mapping(target = "orderItemId", source = "plainOrderId")
    @Mapping(target = "orderNo", source = "externalOrderId")
    @Mapping(target = "skuId", source = "MExternalSkuId")
    @Mapping(target = "skuName", source = "MSkuNameChinese")
    @Mapping(target = "spuId", source = "MExternalSpuId")
    @Mapping(target = "primaryImageUrl", source = "MPrimaryImageUrl")
    @Mapping(target = "orderType", source = "orderType")
    @Mapping(target = "goodsNum", source = "MGoodsNum")
    @Mapping(target = "goodsPrice", source = "MGoodsAmount")
    @Mapping(target = "createTime", source = "createTime")
    @Mapping(target = "payableAmount", source = "payableAmount")
    @Mapping(target = "paymentAmount", source = "paymentAmount")
    @Mapping(target = "status", source = "orderStatus")
    @Mapping(target = "payedTime", source = "payedTime")
    @Mapping(target = "finishTime", source = "finishTime")
    @Mapping(target = "orderAmount", source = "orderAmount")
    OrderInfoByUid tyOrder2OrderInfoByUid(TyOrder tyOrder);

    List<OrderInfoByUid> tyOrders2OrderInfosByUid(List<TyOrder> tyOrder);
}
